#Editor Makefile

include ../Engine/Makefile
include ../MakefileShared

LOCAL_INCLUDE_DIRS= $(LIB_INCLUDES) . ../Engine/ ../Engine/Objects ../Engine/Scripting ../Engine/Networking ../Engine/Helpers ../Engine/Graphics ../Engine/Graphics/UI

LOCAL_LFLAGS=$(LFLAGS) $(LOCAL_INCLUDE_DIRS:%=-I%)

LOCAL_LIBS= $(LIB_LIBS:%=-L%) -Wl,-rpath,. -L$(EXEC_PATH) -lrt -lpthread -lsfml-network -lsfml-system -lsfml-window -lsfml-graphics -llua -lluabindd -ldl -L$(PROJECT_PATH)/glew-1.7.0/lib -lGLEW -lpugixml -lboost_system -lboost_filesystem

LOCAL_FLAGS=$(CFLAGS) $(LOCAL_INCLUDE_DIRS:%=-I%) -MMD -MP -MF

SOURCES=main.cpp \
    Editor.cpp \
    EditorEntity.cpp \
    EditorInstance.cpp \
    EditorRegion.cpp \
    EditorRegionManager.cpp \
    ScriptableInputHandler.cpp \
    EditorScriptEngine.cpp \
    Actions/ClearTileAction.cpp \
    Actions/ClearAreaAction.cpp \
    Actions/FillAction.cpp \
    Actions/ChangeTileAction.cpp \
    Actions/MoveAction.cpp \
    Actions/PasteAction.cpp \
    Actions/MapResizer.cpp \
    Actions/TilePropertyAction.cpp \
    UI/ActionHistoryPanel.cpp \
    UI/FileDialog.cpp \
    UI/MapTab.cpp \
    UI/RightPanel.cpp \
    UI/SpriteSelectorPanel.cpp \
    UI/ClipboardPanel.cpp \
    UI/MapInfoPanel.cpp \
    UI/TileInfoPanel.cpp \
    UI/SpriteInfoPanel.cpp \
    UI/RegionPanel.cpp \
    UI/RegionWindow.cpp \
    $(ROOT_SOURCES:%=../Engine/%) \
    $(OBJECT_SOURCES:%=../Engine/%) \
    $(GRAPHIC_SOURCES:%=../Engine/%) \
    $(UI_SOURCES:%=../Engine/%) \
    $(SCRIPTING_SOURCES:%=../Engine/%) \
    $(CONTENT_SOURCES:%=../Engine/%) \
    $(UTILITY_SOURCES:%=../Engine/%)

OBJECTS=$(SOURCES:.cpp=.o)


.PHONY: all editor clean cleanexec
all: cleanexec editor

editor: $(OBJECTS)
	@echo ""
	@echo "Creating editor executable"
	$(CC) -o $(EXEC_PATH)/editor $(OBJECTS) $(LOCAL_LIBS)

$(OBJECTS): %.o: %.cpp
	@echo ""
	@echo "Compiling $@"
	$(RM) $@.d
	$(CC) $(LOCAL_FLAGS) $(LOCAL_LIBS) -MMD -MP -MF $@.d  -o $@ $<	

cleanexec:
	@echo ""
	@echo "Cleaning Editor"
	$(RM) $(EXEC_PATH)/editor

clean: cleanexec
	$(RM) $(OBJECTS:%=%.d)
	$(RM) $(OBJECTS)
